package com.health.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.health.dao.CheckItemMapper;
import com.health.pojo.CheckItem;
import com.health.service.CheckItemService;
import com.health.vo.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CheckItemServiceImpl implements CheckItemService {

    @Resource
    private CheckItemMapper checkItemMapper;

    @Override
    public PageResult<CheckItem> findPage(Integer pageNow, Integer pageSize, String query) {
        //分页插件
        PageHelper.startPage(pageNow, pageSize);
        //执行查询，Page中包含了查询到的总数，以及分页后的列表
        Page<CheckItem> page = checkItemMapper.findByQuery(query);

        //封装查询到的总数与列表
        return new PageResult<>(page.getTotal(), page.getResult());
    }
}
